package com.hermes.test;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.hermes.biz.common.model.user.UserDO;
import com.hermes.biz.manager.user.UserOperateManager;
import com.hermes.common.action.AsynBaseAction;
import com.hermes.common.util.ParameterParserUtil;
import com.opensymphony.xwork2.ActionSupport;

public class SaveSet  extends ActionSupport{
	public UserOperateManager userOperateManager;
	public UserDO userDO;
	public String result; 
	public String iori;
	


	@Override
	public String execute() throws Exception {
		String hmail = ParameterParserUtil.getParameter("hemail");
		String hnick = ParameterParserUtil.getParameter("hnick");
		String hdesc = ParameterParserUtil.getParameter("hdesc");
		String userid = ParameterParserUtil.getParameter("userid");
		userDO = new UserDO();
		if(null!=userid){
			userDO.setUserId(Long.valueOf(userid));
		}
		else{
			//log error user id null
		}
		userDO.setEmailAddress(hmail);
		userDO.setUserName(hnick);
		userDO.setUserDesciption(hdesc);
		int resultCode = userOperateManager.updateUserMin(userDO);
		
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setContentType("text/html;charset=utf-8");				
		if(resultCode>0){
			response.getWriter().print("ok"); 
		}else{
			response.getWriter().print("faild"); 
		}
		
		response.getWriter().flush();
		response.getWriter().close();
		result = "true";	
	    return SUCCESS;		
	}
	
	//getters and setters
	
	public UserOperateManager getUserOperateManager() {
		return userOperateManager;
	}

	public void setUserOperateManager(UserOperateManager userOperateManager) {
		this.userOperateManager = userOperateManager;
	}
	
	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}


	public String getIori() {
		return iori;
	}

	public void setIori(String iori) {
		this.iori = iori;
	}
}
